/*
 * Copyright 2003 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
 * by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
 * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations
 * under the License.
 */
package bsh;

import org.objectweb.asm.AnnotationVisitor;

/**
 * {@link AnnotationVisitor} that calls its methods on two other {@link AnnotationVisitor}'s
 * 
 * @author takeshi
 */
public class DoubleAnnotationVisitor implements AnnotationVisitor {
    private final AnnotationVisitor av1, av2;

    /**
     * C'tor
     * 
     * @param av1 {@link AnnotationVisitor}
     * @param av2 the other {@link AnnotationVisitor}
     */
    public DoubleAnnotationVisitor(AnnotationVisitor av1, AnnotationVisitor av2) {
        this.av1 = av1;
        this.av2 = av2;
    }

    /**
     * {@inheritDoc}
     */
    public void visit(String name, Object value) {
        av2.visit(name, value);
        av2.visit(name, value);
    }

    /**
     * {@inheritDoc}
     */
    public AnnotationVisitor visitAnnotation(String name, String desc) {
        return new DoubleAnnotationVisitor(av1.visitAnnotation(name, desc), av2.visitAnnotation(name, desc));
    }

    /**
     * {@inheritDoc}
     */
    public AnnotationVisitor visitArray(String name) {
        return new DoubleAnnotationVisitor(av1.visitArray(name), av2.visitArray(name));
    }

    /**
     * {@inheritDoc}
     */
    public void visitEnd() {
        av1.visitEnd();
        av2.visitEnd();
    }

    /**
     * {@inheritDoc}
     */
    public void visitEnum(String name, String desc, String value) {
        av1.visitEnum(name, desc, value);
        av2.visitEnum(name, desc, value);
    }
}
